/**
 * Created by Administrator on 2014/8/11.
 */

var isAttachmentFieldKey = function(key){
    if(key.indexOf('file')>1){
        return true;
    }else{
        return false;
    }
}

exports.attachRequestData = function(req,data){
    var shouldFix = false;
    for(var key in data){
        if(isAttachmentFieldKey(key)){
            shouldFix = true;
        }
    };
    if(shouldFix){
        for(var key in data){
            if(isAttachmentFieldKey(key)){
                req.attach(key,data[key]);
            }else{
                req.field(key,data[key]);
            }
        }
    }else{
        req.send(data);
    }
};